package com.easylinkin.linkappapi.lobar.controller.app;

import com.easylinkin.linkappapi.lobar.dto.UserClockDTO;
import com.easylinkin.linkappapi.lobar.dto.app.LobarUserDTO;
import com.easylinkin.linkappapi.lobar.service.LobarScreenService;
import com.easylinkin.linkappapi.lobar.service.UserClockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

/**
 * @Author: kan yuanfeng
 * @Date: 2022/8/5 10:19
 * @Description: 岗亭大屏
 */
@RestController
@RequestMapping("sentryBox")
@Api(tags = "岗亭大屏")
public class AppSentryBoxController {

  @Autowired
  private UserClockService userClockService;
  @Autowired
  private LobarScreenService lobarScreenService;

  /**
   * 最近10次打卡记录
   */
  @GetMapping("userClock")
  public RestMessage getTenClock(){
    List<UserClockDTO> userClockDTOS = userClockService.getTenClock();
    return RestBuilders.successBuilder().data(userClockDTOS).build();
  }

  /**
   * 查询出勤人数最多的两个
   */
  @GetMapping("topWorkType")
  public RestMessage getBy2WorkType(){
    List<LobarUserDTO> lobarUserDTOS = userClockService.getBy2WorkType();
    return RestBuilders.successBuilder().data(lobarUserDTOS).build();
  }

  /**
   * 查询班组今日考勤数据
   */
  @GetMapping("group")
  public RestMessage getGroup(){
    List<LobarUserDTO> lobarUserDTOS = userClockService.getGroupClock();
    return RestBuilders.successBuilder().data(lobarUserDTOS).build();
  }

  /**
   * 查询作业人员考勤情况
   */
  @GetMapping("taskWorkType")
  public RestMessage getTaskWorkType(){
    Map<String, List<LobarUserDTO>> result = userClockService.getTaskWorkType();
    return RestBuilders.successBuilder().data(result).build();
  }

  /**
   * 岗亭大屏在场人数
   */
  @GetMapping("onNum")
  @ApiOperation("在场人数")
  public RestMessage onNum() {
    Map<String, Integer> map = lobarScreenService.onNum4Box();
    return RestBuilders.successBuilder().data(map).build();
  }
}
